package com.example.mybatisplusdemo.model.dto;

import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@Data
public class PriceComparisonDTO {
    private Long flightId;
    private String flightNumber;
    private String departureAirportCode;
    private String arrivalAirportCode;
    private LocalDateTime departureTime;
    private LocalDateTime arrivalTime;
    private String airlineCode;
    private Integer duration;
    private BigDecimal basePrice;

    private String supplier;
    private BigDecimal supplierPrice;
    private String discountInfo;
    private String refundPolicy;
    private BigDecimal supplierRating;
    private String bookingLink;

    private String serviceClass;
    private Boolean wifiAvailable;
    private Boolean powerUsb;
    private List<String> meals;

    // 计算折扣百分比
    public BigDecimal getDiscountPercent() {
        if (basePrice == null || basePrice.compareTo(BigDecimal.ZERO) == 0) {
            return BigDecimal.ZERO;
        }
        return basePrice.subtract(supplierPrice)
                .divide(basePrice, 4, BigDecimal.ROUND_HALF_UP)
                .multiply(BigDecimal.valueOf(100))
                .setScale(2, BigDecimal.ROUND_HALF_UP);
    }
}